package cn.yitun.chat.yitunserverimapicore.business.group.service.impl;

import cn.yitun.chat.yitunservercommonlib.dataentity.vo.group.GroupHeadVo;
import cn.yitun.chat.yitunservercommonlib.dataentity.vo.group.GroupVo;
import cn.yitun.chat.yitunservercommonlib.dataentity.vo.system.user.UserVo;
import cn.yitun.chat.yitunserverimapicore.business.group.service.GroupCommonService;
import cn.yitun.chat.yitunserverimbase.dao.group.GroupCommonDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 
 * Date 2019-01-23 22:01:34<br>
 * Description 群通用的一些功能，主要是以来其他模块的，比如用户模块，之所以单独分离这个通用功能，<br>
 * 是因为与用户模块有耦合，所有将这块集中到此
 * 
 * @author yitun
 * @since 1.0.0
 */
@Service
@Transactional
public class GroupCommonServiceImpl implements GroupCommonService {

	@Resource
	private GroupCommonDao groupCommonDAO;

	/**
	 * Date 2019-01-21 11:33:35<br>
	 * 获取用户加入或者拥有的群
	 * @author yitun
	 * @param userId
	 * @return
	 * @since 1.0.0
	 */
	public List<GroupVo> getGroupListByGroupMemberUserId(Long userId) {
		return groupCommonDAO.getGroupListByGroupMemberUserId(userId);
	}

	/**
	 * 获取用户加入或者拥有的群 计数
	 * @param userId
	 * @return
	 */
	@Override
	public int countGroupListByGroupMemberUserId(Long userId) {
		return groupCommonDAO.countGroupListByGroupMemberUserId(userId);
	}

	/**
	 * Date 2019-01-21 11:48:20<br>
	 * Description 获取用户已加入群的所有头像
	 * @author yitun
	 * @param userId
	 * @return
	 * @since 1.0.0
	 */
	public List<GroupHeadVo> getGroupHeadListByGroupMemberUserId(Long userId) {
		return groupCommonDAO.getGroupHeadListByGroupMemberUserId(userId);
	}

	/**
	 * Date 2019-01-27 09:17:20<br>
	 * Description 获取群的所有成员
	 * @author yitun
	 * @param groupId
	 * @return
	 * @since 1.0.0
	 */
	public List<UserVo> getUserDataListByGroupMemberGroupId(Long groupId) {
		return groupCommonDAO.getUserDataListByGroupMemberGroupId(groupId);
	}

	/**
	 * Date 2019-01-27 09:17:56<br>
	 * Description 获取用户已经加入群的所有成员
	 * @author yitun
	 * @param userId
	 * @return
	 * @since 1.0.0
	 */
	public List<UserVo> getUserDataListOfAllUserInGroupByGroupMemberUserId(Long userId) {
		return groupCommonDAO.getUserDataListOfAllUserInGroupByGroupMemberUserId(userId);
	}
}
